$.ajax({
    cache : true,
    type : "post",
    url : "/jzweb/stuSignUpCom/cbatchList",
    data:{
        types: 3,
    },
    error : function(request) {
        parent.layer.alert("Connection error");
    },
    success : function(data) {

        if (data.code == 0) {
            let str = '';
            let id = sessionStorage.getItem('trackId');
            data.data?.map(function (v,k){
                // if ( k == 0 ) str += `<option value="">请选择</option>`
                str += `<option value="${v.id}">${v.name}</option>`
            })
            $("#selEbatchId").html(str);
            $("#selEbatchId").val(id)
        } else {
            parent.layer.alert(data.msg)
        }
    }
});


$("#but").click(function (){
    importComExcelFile($('#practicalOperation'),$('#signupForm'),$('#selEbatchId').val(),'/lottery/lotteryBinding')
})

//导入
function importComExcelFile(fileObj, formObj,cbatchId,url) {
    var fileUrl = fileObj.val();
    var suffix = fileUrl.substr(fileUrl.lastIndexOf(".")).toLowerCase();//获得文件后缀名
    if (suffix == '.xls' || suffix == '.xlsx') {
        if (fileUrl) {
            formObj.ajaxSubmit({
                type: "post",
                url: url,
                data: {'cbatchId': cbatchId},
                // header:{'Content-Type':'multipart/form-data'},
                dataType: "json",
                success: function (data) {
                    if (data.code == 0) {
                        $('#exampleTable').bootstrapTable('refresh');
                        parent.load();
                        parent.layer.msg("操作成功");
                        var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                        parent.layer.close(index);
                    } else{
                        layer.msg(data.msg);
                    }
                }, error: function (XMLHttpRequest, textStatus, errorThrown) {
                    console.log(XMLHttpRequest, textStatus, errorThrown)
                    layer.msg('出错了!');
                }
            });
        } else {
            layer.msg('上传的文件不可为空');
            // parent.$.messager.alert('警告', "上传的文件不可为空", 'warning');
        }
    } else {
        layer.msg('请上传正确的Excel表格!');
        // $.messager.alert('警告', "", 'warning');
    }

}